#include "Favorite_Genres_Window.h"

using namespace CinePerfil;
using namespace msclr::interop;

System::Void Favorite_Genres_Window::FGW_saveButton_Click(System::Object^  sender, System::EventArgs^  e)
{
	account->remove_all();

	for (int i = 0; i<this->FGW_genresCheckBoxList->Items->Count; i++){
		if(this->FGW_genresCheckBoxList->GetItemChecked(i))
		{
			account->add_genre(marshal_as<string>(this->FGW_genresCheckBoxList->GetItemText(this->FGW_genresCheckBoxList->Items[i])));
		}
	}
	this->Owner->Show();
	this->Close();
}
System::Void Favorite_Genres_Window::FGW_cancelButton_Click(System::Object^  sender, System::EventArgs^  e)
{
	this->Owner->Show();
	this->Close();
}

System::Void Favorite_Genres_Window::FGW_load_GenresChecked(void)
{
	vector<string> genres = account->get_favorite_genres();
	for (unsigned int i = 0; i < genres.size(); i++)
	{
			this->FGW_genresCheckBoxList->SetItemChecked(this->FGW_genresCheckBoxList->Items->IndexOf(marshal_as<String^>(genres[i])), true);
	}
}